home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Examples / DemoText / UTabTEView.a < prev    next >
Encoding:
Text File  |  1990-10-25  |  6.0 KB  |  235 lines  |  [TEXT/MPS ]

  1. ; Copyright © 1987-1990 by Apple Computer, Inc.  All rights reserved.
  2. ; UTabTEView assembly language routines
  3.                 CASE     ON
  4.                 STRING    ASIS
  5.                 
  6.                 PRINT            OFF
  7.                 INCLUDE         'ToolEqu.a'
  8.                 INCLUDE         'QuickEqu.a'
  9.  
  10.                 INCLUDE         'Macros.a'
  11.                 LOAD            'ProgStrucMacs.d'
  12.                 LOAD            'FlowCtlMacs.d'
  13.                 PRINT            ON
  14.     
  15. **************************************************************************
  16. **                 Record templates and Global Data area                     **
  17. **************************************************************************
  18. GlobalData        RECORD EXPORT
  19.     ALIGN 4
  20.         EXPORT    curTabTEView, HookedCQDProcsPtrOffset, OldTEHooksRecOffset, InMyHook
  21.  
  22. HookedCQDProcsPtrOffset    DS.W        1            ; Offset in SELF of the Pointer to the
  23.                                                 ; HookedTheProcsPointer
  24. OldTEHooksRecOffset        DS.W        1            ; Offset in SELF of the Pointer to the
  25.                                                 ; OldTEHooksRec
  26. curTabTEView            DC.L        0            ; provides context from
  27.                                                 ; the TE Hooks to the Bottleneck procs
  28. InMyHook                DC.W        0
  29.                 ENDR
  30.  
  31. ; OldTEHooksRec structure
  32.  
  33. OldTEHooksRec        RECORD EXPORT
  34. drawHook          EQU         0                         ; [ProcPtr]
  35. widthHook          EQU         4                         ; [ProcPtr]
  36. hitTestHook      EQU         8                         ; [ProcPtr]
  37. EOLHook          EQU         $C                         ; [ProcPtr]
  38.                 ENDR
  39.  
  40.  
  41. ;========================================
  42. ; myTEDrawHook
  43. ;========================================
  44. ; on entry        A3: pointer to TERec
  45. ;                A1: Scratch
  46. ;
  47. EXPORT PROCEDURE MYTEDRAWHOOK
  48.     Seg         'TERes'
  49.     VAR oldGrafPort:L                ; the GrafPort found in the TE
  50.     VAR oldGrafProcs:L                ; the grafprocs pointer found in the TE's grafport
  51.     VAR oldCurTEView:L                ; the saved setting of the curTEView
  52.  
  53.     BEGIN with=GlobalData
  54.  
  55.                 MOVEM.L        A2/A4,-(SP)        ; we'll need this back
  56.  
  57. ; get SELF into A4 from the refcon
  58.                 MOVE.L        teFont(A3),A1    ;get handle
  59.                 MOVE.L        (A1),A1            ;first dereference
  60.                 MOVE.L        teRefCon(A1),A4
  61.  
  62. ; Make SELF available to the hooked grafprocs that will be invoked later
  63. ; save the old curTabTEView first
  64.                 MOVE.L        curTabTEView(A5), oldCurTEView(FP)
  65.                 MOVE.L        A4,curTabTEView(A5)
  66.  
  67. ; get pointer to our hooked grafprocs into A1
  68.                 MOVE.L        (A4),A1
  69.                 Add.W        HookedCQDProcsPtrOffset(A5), A1
  70.                 MOVE.L        (A1),A1
  71.  
  72. ; get the port in use by TE
  73.                 MOVEA.L        teGrafPort(A3),A2
  74.                 MOVE.L        A2,oldGrafPort(FP)    ;we'll need this back
  75.  
  76. ; save its old grafprocs pointer
  77.                 MOVE.L        grafProcs(A2),oldGrafProcs(FP)
  78.  
  79. ; stuff in the pointer to our grafprocs
  80.                 MOVE.L        A1,grafProcs(A2)
  81.  
  82. ; get pointer to the oldDrawHook
  83.                 MOVE.L        (A4),A1
  84.                 Add.W        OldTEHooksRecOffset(A5), A1
  85.                 MOVE.L        OldTEHooksRec.drawHook(A1),A1
  86.  
  87. ; restore the munged registers
  88.                 MOVEM.L        (SP)+,A2/A4
  89.  
  90.  
  91. ; Call through to the original routine
  92.                 JSR            (A1)
  93.                 
  94.  
  95. ; restore the old curTabTEView, grafprocs and flag that showed we were hooked in
  96.  
  97.                 MOVE.L        oldCurTEView(FP), curTabTEView(A5)
  98.                 MOVE.L        oldGrafPort(FP),A1
  99.                 MOVE.L        oldGrafProcs(FP),grafProcs(A1)
  100.  
  101.                 RETURN
  102.                 EndP
  103.  
  104.  
  105. ;========================================
  106. ; myTEWidthHook
  107. ;========================================
  108. ; on entry        A3: pointer to TERec
  109. ;                A1: Scratch
  110. ;
  111. EXPORT PROCEDURE MYTEWIDTHHOOK
  112.     Seg         'TERes'
  113.     VAR oldGrafPort:L                ; the GrafPort found in the TE
  114.     VAR oldGrafProcs:L                ; the grafprocs pointer found in the TE's grafport
  115.     VAR oldCurTEView:L                ; the saved setting of the curTEView
  116.  
  117.     BEGIN with=GlobalData
  118.  
  119.                 MOVEM.L        A2/A4,-(SP)        ; we'll need this back
  120.  
  121. ; get SELF into A4 from the refcon
  122.                 MOVE.L        teFont(A3),A1    ;get handle
  123.                 MOVE.L        (A1),A1            ;first dereference
  124.                 MOVE.L        teRefCon(A1),A4
  125.  
  126. ; Make SELF available to the hooked grafprocs that will be invoked later
  127. ; save the old curTabTEView first
  128.                 MOVE.L        curTabTEView(A5), oldCurTEView(FP)
  129.                 MOVE.L        A4,curTabTEView(A5)
  130.  
  131. ; get pointer to our hooked grafprocs into A1
  132.                 MOVE.L        (A4),A1
  133.                 Add.W        HookedCQDProcsPtrOffset(A5), A1
  134.                 MOVE.L        (A1),A1
  135.  
  136. ; get the port in use by TE
  137.                 MOVEA.L        teGrafPort(A3),A2
  138.                 MOVE.L        A2,oldGrafPort(FP)    ;we'll need this back
  139.  
  140. ; save its old grafprocs pointer
  141.                 MOVE.L        grafProcs(A2),oldGrafProcs(FP)
  142.  
  143. ; stuff in the pointer to our grafprocs
  144.                 MOVE.L        A1,grafProcs(A2)
  145.  
  146. ; get pointer to the oldDrawHook
  147.                 MOVE.L        (A4),A1
  148.                 Add.W        OldTEHooksRecOffset(A5), A1
  149.                 MOVE.L        OldTEHooksRec.widthHook(A1),A1
  150.  
  151. ; restore the munged registers
  152.                 MOVEM.L        (SP)+,A2/A4
  153.  
  154.  
  155. ; Call through to the original routine
  156.                 JSR            (A1)
  157.                 
  158.  
  159. ; restore the old curTabTEView, grafprocs and flag that showed we were hooked in
  160.  
  161.                 MOVE.L        oldCurTEView(FP), curTabTEView(A5)
  162.                 MOVE.L        oldGrafPort(FP),A1
  163.                 MOVE.L        oldGrafProcs(FP),grafProcs(A1)
  164.  
  165.                 RETURN
  166.                 EndP
  167.  
  168.  
  169. ;========================================
  170. ; myTEHitTestHook
  171. ;========================================
  172. ; on entry        A3: pointer to TERec
  173. ;                A1: Scratch
  174. ;
  175. ;
  176. ;
  177. ;
  178. EXPORT PROCEDURE MYTEHITTESTHOOK
  179.     Seg         'TERes'
  180.     VAR oldGrafPort:L                ; the GrafPort found in the TE
  181.     VAR oldGrafProcs:L                ; the grafprocs pointer found in the TE's grafport
  182.     VAR oldCurTEView:L                ; the saved setting of the curTEView
  183.  
  184.     BEGIN with=GlobalData
  185.  
  186.                 MOVEM.L        A2/A4,-(SP)        ; we'll need this back
  187.  
  188. ; get SELF into A4 from the refcon
  189.                 MOVE.L        teFont(A3),A1    ;get handle
  190.                 MOVE.L        (A1),A1            ;first dereference
  191.                 MOVE.L        teRefCon(A1),A4
  192.  
  193. ; Make SELF available to the hooked grafprocs that will be invoked later
  194. ; save the old curTabTEView first
  195.                 MOVE.L        curTabTEView(A5), oldCurTEView(FP)
  196.                 MOVE.L        A4,curTabTEView(A5)
  197.  
  198. ; get pointer to our hooked grafprocs into A1
  199.                 MOVE.L        (A4),A1
  200.                 Add.W        HookedCQDProcsPtrOffset(A5), A1
  201.                 MOVE.L        (A1),A1
  202.  
  203. ; get the port in use by TE into A2
  204.                 MOVEA.L        teGrafPort(A3),A2
  205.                 MOVE.L        A2,oldGrafPort(FP)    ;we'll need this back
  206.  
  207. ; save its old grafprocs pointer
  208.                 MOVE.L        grafProcs(A2),oldGrafProcs(FP)
  209.  
  210. ; stuff in the pointer to our grafprocs
  211.                 MOVE.L        A1,grafProcs(A2)
  212.  
  213. ; get pointer to the oldDrawHook
  214.                 MOVE.L        (A4),A1
  215.                 Add.W        OldTEHooksRecOffset(A5), A1
  216.                 MOVE.L        OldTEHooksRec.hitTestHook(A1),A1
  217.  
  218. ; restore the munged registers
  219.                 MOVEM.L        (SP)+,A2/A4
  220.  
  221.  
  222. ; Call through to the original routine
  223.                 JSR            (A1)
  224.                 
  225.  
  226. ; restore the old curTabTEView, grafprocs and flag that showed we were hooked in
  227.  
  228.                 MOVE.L        oldCurTEView(FP), curTabTEView(A5)
  229.                 MOVE.L        oldGrafPort(FP),A1
  230.                 MOVE.L        oldGrafProcs(FP),grafProcs(A1)
  231.  
  232.                 RETURN
  233.                 EndP
  234.  
  235.                 END